package com.markedquilt.controller;
/*
 * PackageName: com.markedquilt.my_session.controller
 * Author:   coke
 * Date:     Created in 2020/11/23 20:47
 * Description:
 * History:
 * <author>        <time>             <version>          <desc>
 * 作者姓名         修改时间            版本号              描述
 * coke           2020/11/23 20:47     1.0
 */

import com.markedquilt.entity.Resume;
import com.markedquilt.service.ResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author ZhangKe
 * @Description
 * @date 2020/11/23 20:47.
 */
@Controller
@RequestMapping("/resume")
public class ResumeController {

    @Autowired
    private ResumeService resumeService;

    @RequestMapping("/list")
    public String queryResumeList(Model model) throws Exception {
        model.addAttribute("resumeList",resumeService.getList());
        return "/resumeList.jsp";
    }

    @RequestMapping("get")
    public String getById(Integer id,Model model) {
        Resume resume = null;
        if(id==null) {
            resume = new Resume();
        }else{
            resume = resumeService.getById(id);
        }

        model.addAttribute("resume",resume);
        return "/resumeEdit.jsp";
    }

    @RequestMapping("update")
    public String updateResume(Resume resume) {
        resumeService.update(resume);
        return "redirect:resumeList";
    }


    @RequestMapping("delete")
    public String resumeDelete(Integer id) {
        resumeService.deleteById(id);
        return "redirect:resumeList";
    }


}
